<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../img/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>

<script language="javascript">
function checkSubmit()
{
  if(document.form1.group_name.value == 0)
  {
	   alert("请添加权限组名称！");
	   return false;
  }
}
function module1(mid, bool)
{
	var module = document.getElementById("check_"+mid);
	if (bool == true)
	{
		module.checked = true;
	}
	else
	{
		if (module.checked == true)
		{
			set_module_checkbox("module_no_c[]", module.id, true);
			set_module_checkbox("module_have_c[]", module.id, true);
		}
		else
		{
			set_module_checkbox("module_no_c[]", module.id);
			set_module_checkbox("module_have_c[]", module.id);
		}
	}
}
function module2(mid, pid, bool)
{  
	var module = document.getElementById("check_"+pid+"_"+mid);	
	if (module.checked == true)
	{
		module1(pid, true);
		set_module_checkbox("module_no_c[]", module.id, true);
		set_module_checkbox("module_have_c[]", module.id, true);
	}
	else
	{
		   
		set_module_checkbox("module_no_c[]", module.id);
		set_module_checkbox("module_have_c[]", module.id);		
	}
	
}
function module3(mid, pid, ppid)
{
	var module = document.getElementById("check_"+ppid+"_"+pid+"_"+mid);
	if (module.checked == true)
	{
		module2(pid, ppid, true);
	}
}
function set_module_checkbox(namestr, mid, bool)
{
	if (bool)
	{
		bool = bool;
	}
	else
	{  
	    
		var head =  mid.substr(0,mid.lastIndexOf("_"))		
		if($("input[id^='"+head+"']:checked").length == 1)
		{  
		   $("input[id^='"+head+"']:checked").each(function(){
			$(this).attr("checked",false)
		   })
		  
		}
		bool = false;
		
	}	
	
	var cInput = document.getElementsByName(namestr);
	var module = document.getElementById(mid);
	
	for (var i = 0; i < cInput.length; i++)
	{
		if (cInput[i].id.length > module.id.length)
		{
			if (cInput[i].id.substr(0, module.id.length+1) == module.id+"_")
			{
				cInput[i].checked = bool;
			}
		}
	}
}
</script>
</head>
<body leftmargin='15' topmargin='10' bgcolor="#FFFFFF">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" id="head1" style="border-bottom:1px solid #CCCCCC">
  	<tr>
    	<td colspan="2">
        	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D1DDAA">
                <tr>
                    <td height="26" background="../img/newlinebg3.gif">
                        <table width="98%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td align="right">
                                    <input type='button' class="coolbg np" onClick="location='admin_index_main.php';" value='返回' />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">
    <tr>
	<td height="24" colspan="4" class="bline">
	    <table width="800" border="0" cellspacing="0" cellpadding="0">
		<tr>		  
		    <td class="bline" width="130">&nbsp;当前所属的权限组是：</td>
		    <td class="bline"><{$admin_group_data.group_name}></td>
		</tr>
	    </table>      
	</td>
    </tr>
</table>


<form name="form1" action="admin_act.php?action=save_warrant&aid=<{$admin_index_data.admin_id}>" enctype="multipart/form-data" method="post" onSubmit="return checkSubmit()">
<table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">
<{foreach item=moduleInfo from=$group_moudle_list}>
  	<tr>
    	<td height="24px" colspan="4" class="bline">
    		<table width="800px" border="0" cellspacing="0" cellpadding="0">
    			<tr>
    				<td>
    				<{if $moduleInfo.status == "have"}>
			    		<input type="hidden" name="module_<{$moduleInfo.status}>_h[]" value="<{$moduleInfo.module_id}>" />
			                <input type="checkbox" onclick="module1(<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>" name="module_<{$moduleInfo.status}>_c[]" value="<{$moduleInfo.module_id}>"  checked="checked" disabled title="该权限属于<{$admin_group_data.group_name}>组" />  <{$moduleInfo.module_name}>
			        <{else}>
                                    <{if $moduleInfo.special == 1 }>
                                         <input onclick="module1(<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>" type="checkbox" name="module_<{$moduleInfo.status}>_c[]" value="<{$moduleInfo.module_id}>"   checked="checked"/> <{$moduleInfo.module_name}>
                                   <{else}>
                                        <input onclick="module1(<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>" type="checkbox" name="module_<{$moduleInfo.status}>_c[]" value="<{$moduleInfo.module_id}>" /> <{$moduleInfo.module_name}>
                                     <{/if}>
                                <{/if}>
    				</td>
    			</tr>
    		</table>
        </td>
    </tr>
    <{if $moduleInfo.module_list2}>
    <tr>
        <td height="24px" colspan="4" class="bline">
      		<table width="800px" border="0" cellspacing="0" cellpadding="0">
        		<tr>
        			<td width="20px"></td>
                	<td>
                	<{foreach item=moduleInfo2 from=$moduleInfo.module_list2}>
                	<{if $moduleInfo2.status == "have"}>
		    			<input type="hidden" name="module_<{$moduleInfo2.status}>_h[]" value="<{$moduleInfo2.module_id}>" />
					<input onclick="module2(<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>" type="checkbox" name="module_<{$moduleInfo2.status}>_c[]" value="<{$moduleInfo2.module_id}>" checked="checked" disabled title="该权限属于<{$admin_group_data.group_name}>组"/>  <{$moduleInfo2.module_name}>
		           	<{else}>
				     <{if $moduleInfo2.special == 1 }>		    				
					 <input onclick="module2(<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>" type="checkbox" name="module_<{$moduleInfo2.status}>_c[]" value="<{$moduleInfo2.module_id}>" checked="checked"/> <{$moduleInfo2.module_name}>
				    <{else}>
					 <input onclick="module2(<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>" type="checkbox" name="module_<{$moduleInfo2.status}>_c[]" value="<{$moduleInfo2.module_id}>"/> <{$moduleInfo2.module_name}>				  
				    <{/if}>
				<{/if}>
		        	<{if $moduleInfo2.module_list3}>
		        		(
		        		<{foreach item=moduleInfo3 from=$moduleInfo2.module_list3}>
		        			<{if $moduleInfo3.status == "have"}>
				    			<input type="hidden" name="module_<{$moduleInfo3.status}>_h[]" value="<{$moduleInfo3.module_id}>" />
				            	<input onclick="module3(<{$moduleInfo3.module_id}>,<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>_<{$moduleInfo3.module_id}>" type="checkbox" name="module_<{$moduleInfo3.status}>_c[]" value="<{$moduleInfo3.module_id}>"  disabled title="该权限属于<{$admin_group_data.group_name}>组" checked="checked" />  <{$moduleInfo3.module_name}>
				           	<{else}>
						     <{if $moduleInfo2.special == 1 }>	
							 <input onclick="module3(<{$moduleInfo3.module_id}>,<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>_<{$moduleInfo3.module_id}>" type="checkbox" name="module_<{$moduleInfo3.status}>_c[]" value="<{$moduleInfo3.module_id}>" checked="checked"/> <{$moduleInfo3.module_name}>
						     <{else}>
						     <input onclick="module3(<{$moduleInfo3.module_id}>,<{$moduleInfo2.module_id}>,<{$moduleInfo.module_id}>)" id="check_<{$moduleInfo.module_id}>_<{$moduleInfo2.module_id}>_<{$moduleInfo3.module_id}>" type="checkbox" name="module_<{$moduleInfo3.status}>_c[]" value="<{$moduleInfo3.module_id}>" /> <{$moduleInfo3.module_name}>
						     <{/if}>
						<{/if}>
		        		<{/foreach}>
		        		)
		        	<{/if}>
		        	<{/foreach}>
                    </td>
        		</tr>
      		</table>      
    	</td>
  	</tr>
  	<{/if}>
<{/foreach}>
</table>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
    	<td height="56">
			<table width="98%" border="0" cellspacing="1" cellpadding="1">
        		<tr>
          			<td align="center">
          				<table width="214" border="0" cellspacing="0" cellpadding="0" >
              				<tr>
				                <td width="115">
				                    <input name="imageField" type="image" src="../img/button_ok.gif" width="60" height="22" class="np" border="0"  style="cursor:pointer; ">
				                </td>
				                <td width="99">
				                	<img src="../img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:pointer; ">
				                </td>
			              	</tr>
						</table>
					</td>
    			</tr>
			</table>
		</td>
	</tr>
</table>
</form>		
</body>

</html>